package com.example.widgetcase.slice.taperchart;

import com.example.widget_lib.widget.taperchart.HorTaperChart;
import com.example.widgetcase.ResourceTable;
import com.example.widgetcase.slice.BaseSlice;
import ohos.aafwk.content.Intent;

import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class ScrollTaperChartAbility extends BaseSlice {
    private HorTaperChart hor_tchart;
    @Override
    public int getChildUIContent() {
        return ResourceTable.Layout_ability_scroll_taper_chart;
    }

    @Override
    protected void onStart(Intent intent) {
        super.onStart(intent);
        hor_tchart = (HorTaperChart) findComponentById(ResourceTable.Id_hor_tchart);
        syncTaperChartData();
    }

    private void syncTaperChartData() {
        hor_tchart.offSetXy(48f);
        hor_tchart.setDrawTopValue(true);
        hor_tchart.setInterSpace(28);

        List<String> keys = new ArrayList<>();
        for (int i = 0; i < 12; i++) {
            keys.add("第"+ (i + 1)+ "次");
        }
        List<Float> values = new ArrayList<>();
        for (int i = 0; i < 12; i++) {
            values.add((float) (new SecureRandom().nextInt(100)));
        }
        hor_tchart.setData(keys, values);
    }
}
